<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page isELIgnored='false'%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="conversation.css" rel="STYLESHEET" type="text/css">
<title>Conversation List</title>
<jsp:include page="scripts/js_tools.jsp" />
<!--  jsp:include page="scripts/export.jsp" / -->
</head>
<body>
<!--        Header         -->
<jsp:include page="scripts/headerAnnotate.jsp">
<jsp:param name="title" value="Annotation Assignments" />
</jsp:include>
<!--        List           -->
<div class="list">
<br /> <br />
<form:form commandName="assignments">
<table>
  <tr>
    <th>Id</th>
    <c:if test="${anno_user.role == 1}">
    <th>Annotator</th>
    </c:if>
    <th>Turns</th>    
    <th>Msgs</th>
    <th>Annotated</th>
    <th>Progress</th>    
    <th><a href="#agreements">Agreements*</a></th>
    <th>Current Status</th>
    <th>
      Assigned Annotators
    </th>
    <th></th>
  </tr>
  <c:forEach items="${assignments.assignmentsArray}" var="assignment" varStatus="counter">
    <tr>
      <td>
        <a href='annotateconversation.html?conversationId=<c:out value="${assignment.conversation.conversationId}"/>'>
          <c:out value="${assignment.conversation.conversationId}" /> 
        </a>
      </td>
      <c:if test="${anno_user.role == 1}">
      <td><c:out value="${assignment.user.userName}" /></td>
      </c:if>
      <td><c:out
        value="${assignment.conversation.numMessageTurns}" /></td>
      <td><c:out value="${assignment.conversation.numMessages}" /></td>
      <td><c:out value="${assignment.numAnnotated}" /></td>
      <td><c:if test="${assignment.progressEstimate == '100%'}"><font color="green">100%</font></c:if>
          <c:if test="${assignment.progressEstimate != '100%'}"><c:out value="${assignment.progressEstimate}" /></c:if>
      </td>
      <td>
        <c:if test="${anno_user.role == 1 || assignment.status == 1}">
        <c:out escapeXml='false' value="${assignment.averageFunctionAgreementString}" /> /
        <c:out escapeXml='false' value="${assignment.messageWiseAgreementString}" /> /
      	  <c:out escapeXml='false' value="${assignment.averageAgreementString}" />
      	    
      	</c:if>
      </td>
      <td>
        <c:if test="${assignment.status == 0}">
        In progress <form:radiobutton path="assignmentsArray[${counter.index}].status" value='0' />
        </c:if>
        <c:if test="${assignment.status == 1}">
        In progress <form:radiobutton disabled="true" path="assignmentsArray[${counter.index}].status" value='0' />
        </c:if>        
        Completed <form:radiobutton path="assignmentsArray[${counter.index}].status" value='1' />        
      </td>
      <td>
      <c:if test="${anno_user.role == 1 || assignment.status == 1}">
        <c:forEach items="${assignment.conversation.annotators}" var="annotator">
         <c:if test="${assignment.user.userName != annotator.userName}">
           <c:out value="${annotator.userName}" />
           </c:if>
        </c:forEach>
      </c:if>
      </td>              
      <td>
      <c:if test="${assignment.status == 0}">
        <a href='annotateconversation.html?conversationId=<c:out value="${assignment.conversation.conversationId}"/>'>        
          [annotate]
        </a>
      </c:if>
      <c:if test="${anno_user.role == 1 || assignment.status == 1}">
        <a href='browseconversation.html?conversationId=<c:out value="${assignment.conversation.conversationId}"/>'>        
        [browse]
        </a>      
      </c:if>
      </td>
    </tr>
  </c:forEach>
  <tr>
    <td></td><td></td><td></td><td></td><td></td>
    <td><input type="submit" value="Save Status Change(s)"></input></td><td></td><td></td>   
  </tr>
</table>
</form:form>
</div>
<div>
<p>
<a name="agreements">The agreements are measured in three ways: 
1) agreed on dialogue act functions; 2) agreed on both dialogue act functions and domains; and 3) agreed on dialogue acts and text segmentations.</a>
</p>
</div>
<jsp:include page="scripts/footer.jsp" />
</body>
</html>
